package com.ahuan.service.Impl;

import com.ahuan.domain.Dept;
import com.ahuan.mapper.DeptMapper;
import com.ahuan.service.DeptService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> queryDeptList(Integer page,Integer limit) {
        PageHelper.startPage(page,limit);
        return deptMapper.selectDeptList();
    }

    @Override
    public boolean addDept(Dept dept) {
        deptMapper.insertDept(dept);
        System.out.println(dept.getEditUser());
        System.out.println(dept.getDeptId());
        return  dept.getDeptId() != null;
    }

    @Override
    public boolean editDept(Dept dept) {
        return deptMapper.updateDept(dept) > 0;
    }

    @Override
    public boolean delete(String deptId) {
        return deptMapper.deleteDept(deptId) > 0;
    }
}
